<%--
  Created by IntelliJ IDEA.
  User: lw
  Date: 2021/6/29
  Time: 12:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="<c:url value="/static/css/font.css"/>">
    <link rel="stylesheet" href="<c:url value="/static/css/xadmin.css"/>">
    <link rel="stylesheet" href="<c:url value="/static/lib/layui/css/layui.css"/>">
    <script type="text/javascript" src="<c:url value="/static/lib/layui/layui.js"/>" charset="utf-8"></script>
    <script type="text/javascript" src="<c:url value="/static/js/xadmin.js"/>"></script>
</head>
<body>
<div class="layui-container" style="width: 600px;height: 400px">
    <form class="layui-form" id="fpfjform">
        <div class="layui-form-item">
            <label class="layui-form-label">分配房间</label>
            <div class="layui-input-inline">
                <select name="fpfj" lay-filter="fpfj1">
                    <option value="">请选择房间</option>
                    <c:forEach items="${address}" var="model">
                        <option value="${model[1]}">${model[0]}</option>
                    </c:forEach>
                </select>
            </div>

<%--            <div class="layui-input-inline">--%>
<%--                <select name="fpfj2">--%>
<%--                    <option value="">请选择楼栋号</option>--%>
<%--                    <c:forEach items="${parkings}" var="parking">--%>
<%--                        <option value="${parking.pNo}">${parking.pNo}</option>--%>
<%--                    </c:forEach>--%>
<%--                </select>--%>
<%--            </div>--%>

<%--            <div class="layui-input-inline">--%>
<%--                <select name="fpfj3">--%>
<%--                    <option value="">请选择单元号</option>--%>
<%--                    <c:forEach items="${parkings}" var="parking">--%>
<%--                        <option value="${parking.pNo}">${parking.pNo}</option>--%>
<%--                    </c:forEach>--%>
<%--                </select>--%>
<%--            </div>--%>

<%--            <div class="layui-input-inline">--%>
<%--                <select name="fpfj4">--%>
<%--                    <option value="">请选择房间号</option>--%>
<%--                    <c:forEach items="${parkings}" var="parking">--%>
<%--                        <option value="${parking.pNo}">${parking.pNo}</option>--%>
<%--                    </c:forEach>--%>
<%--                </select>--%>
<%--            </div>--%>
        </div>
        <input type="hidden" name="usNo" value="${usNo}">
        <div class="layui-form-item">
            <button class="layui-btn" lay-filter="fpfj" lay-submit="">确定</button>
        </div>
    </form>
</div>

<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //监听小区下拉框选中事件
        // form.on('select(fpfj1)', function(obj){
        //     alert(obj.value)
        //     $.ajax({
        //         data:{
        //             fpfj:"fpfj1",
        //
        //         }
        //
        //     })
        // });

        //监听提交
        form.on('submit(fpfj)', function(data){
            $.ajax({
                type:"post",
                url:"<c:url value="/fpfj" />",
                data:$('#fpfjform').serialize(),
                success: function(result){
                    // alert("POST请求到的数据：" + result);
                    if (result === "true"){
                        layer.alert("分配成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();

                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    }else {
                        layer.alert("分配失败", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();

                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    }
                }
            })
            return false;
        });


    });
</script>
</body>
</html>
